<template>
  <div class="error-page">
    <div class="error-container">
      <div class="error-content">
        <div class="error-image">
          <svg viewBox="0 0 404 300" class="error-svg">
            <!-- 404数字 -->
            <text x="50%" y="50%" text-anchor="middle" dominant-baseline="middle" class="error-text">
              404
            </text>
            <!-- 装饰元素 -->
            <circle cx="100" cy="100" r="20" class="decoration-circle" />
            <circle cx="300" cy="200" r="15" class="decoration-circle" />
            <rect x="320" y="80" width="30" height="30" class="decoration-rect" />
          </svg>
        </div>
        
        <div class="error-info">
          <h1 class="error-title">页面未找到</h1>
          <p class="error-description">
            抱歉，您访问的页面不存在或已被移除。
          </p>
          <p class="error-suggestion">
            请检查URL是否正确，或者返回首页继续浏览。
          </p>
          
          <div class="error-actions">
            <el-button type="primary" @click="goHome" size="large">
              <el-icon><House /></el-icon>
              返回首页
            </el-button>
            <el-button @click="goBack" size="large">
              <el-icon><ArrowLeft /></el-icon>
              返回上页
            </el-button>
            <el-button @click="refresh" size="large">
              <el-icon><Refresh /></el-icon>
              刷新页面
            </el-button>
          </div>
        </div>
      </div>
      
      <div class="helpful-links">
        <h3>您可能需要：</h3>
        <el-row :gutter="20">
          <el-col :span="8">
            <el-card shadow="hover" class="link-card" @click="navigateTo('/dashboard')">
              <div class="link-content">
                <el-icon class="link-icon"><Monitor /></el-icon>
                <div>
                  <h4>设备监控</h4>
                  <p>查看设备状态和监控信息</p>
                </div>
              </div>
            </el-card>
          </el-col>
          <el-col :span="8">
            <el-card shadow="hover" class="link-card" @click="navigateTo('/devices')">
              <div class="link-content">
                <el-icon class="link-icon"><VideoCamera /></el-icon>
                <div>
                  <h4>设备管理</h4>
                  <p>管理和配置ONVIF设备</p>
                </div>
              </div>
            </el-card>
          </el-col>
          <el-col :span="8">
            <el-card shadow="hover" class="link-card" @click="navigateTo('/discovery')">
              <div class="link-content">
                <el-icon class="link-icon"><Search /></el-icon>
                <div>
                  <h4>设备发现</h4>
                  <p>自动发现网络中的设备</p>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </div>
      
      <div class="error-footer">
        <el-alert
          title="需要帮助？"
          type="info"
          description="如果您认为这是一个错误，请联系系统管理员或查看帮助文档。"
          show-icon
          :closable="false"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { House, ArrowLeft, Refresh, Monitor, VideoCamera, Search } from '@element-plus/icons-vue'

const router = useRouter()

const goHome = () => {
  router.push('/')
  ElMessage.success('已返回首页')
}

const goBack = () => {
  if (window.history.length > 1) {
    router.go(-1)
  } else {
    router.push('/')
  }
}

const refresh = () => {
  window.location.reload()
}

const navigateTo = (path) => {
  router.push(path)
}
</script>

<style scoped>
.error-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.error-container {
  max-width: 1200px;
  width: 100%;
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.error-content {
  display: flex;
  align-items: center;
  padding: 60px 40px;
  gap: 60px;
}

.error-image {
  flex: 1;
  display: flex;
  justify-content: center;
}

.error-svg {
  width: 100%;
  max-width: 400px;
  height: 300px;
}

.error-text {
  font-size: 120px;
  font-weight: bold;
  fill: #409eff;
  opacity: 0.8;
}

.decoration-circle {
  fill: #67c23a;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

.decoration-rect {
  fill: #e6a23c;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.error-info {
  flex: 1;
  text-align: left;
}

.error-title {
  font-size: 48px;
  color: #303133;
  margin-bottom: 20px;
  font-weight: bold;
}

.error-description {
  font-size: 18px;
  color: #606266;
  margin-bottom: 15px;
  line-height: 1.6;
}

.error-suggestion {
  font-size: 16px;
  color: #909399;
  margin-bottom: 40px;
  line-height: 1.6;
}

.error-actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.error-actions .el-button {
  padding: 12px 24px;
  font-size: 16px;
}

.helpful-links {
  padding: 40px;
  background: #f8f9fa;
  border-top: 1px solid #ebeef5;
}

.helpful-links h3 {
  color: #303133;
  margin-bottom: 20px;
  font-size: 20px;
}

.link-card {
  cursor: pointer;
  transition: all 0.3s ease;
  height: 120px;
}

.link-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.link-content {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 100%;
}

.link-icon {
  font-size: 32px;
  color: #409eff;
}

.link-content h4 {
  margin: 0 0 5px 0;
  color: #303133;
  font-size: 16px;
}

.link-content p {
  margin: 0;
  color: #909399;
  font-size: 14px;
}

.error-footer {
  padding: 30px 40px;
  background: white;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .error-content {
    flex-direction: column;
    padding: 40px 20px;
    gap: 40px;
    text-align: center;
  }
  
  .error-title {
    font-size: 36px;
  }
  
  .error-actions {
    justify-content: center;
  }
  
  .helpful-links {
    padding: 30px 20px;
  }
  
  .error-footer {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .error-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .error-actions .el-button {
    width: 200px;
  }
}
</style>